home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 339 < prev    next >
Internet Message Format  |  1996-08-06  |  2KB

  1. Path: inforamp.net!usenet
  2. From: pcurran@inforamp.net (Peter Curran)
  3. Newsgroups: comp.std.c
  4. Subject: Stdarg NULLs (was how pass argv to exec cde)
  5. Date: Tue, 20 Feb 1996 15:35:04 GMT
  6. Organization: PSC Enterprises
  7. Message-ID: <4gcota$h79@sam.inforamp.net>
  8. References: <4fbd0o$aj5@sunsic.si.univ-compiegne.fr> <4fs44l$3p8@moody.mchh.siemens.de> <KANZE.96Feb19172802@slsvewt.lts.sel.alcatel.de>
  9. Reply-To: pcurran@inforamp.net
  10. NNTP-Posting-Host: ts45-08.tor.inforamp.net
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. On 19 Feb 1996 16:28:01 GMT in article
  14. <KANZE.96Feb19172802@slsvewt.lts.sel.alcatel.de>
  15.     kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763) (James Kanze
  16. US/ESC 60/3/141 #40763) wrote:
  17.  
  18. >In article <4fs44l$3p8@moody.mchh.siemens.de> Ronald Fischer
  19. ><ronald.fischer@uebemc.siemens.de> writes:
  20.  
  21. >|> The correct code is either
  22. >|> {
  23. >|>   char const path[]="c:\\dos\\edit.com";
  24. >|>   execl(path,path,"zoo.asm",0);
  25. >                               ^
  26.  
  27. >Wrong.  This is one of the rare cases where you have to cast the 0 (or
  28. >NULL) to the correct type.
  29.  
  30. This leads to one of my long-imagined ideas for improving C . . . eliminating
  31. this need to cast NULL (as well as numerous other benefits, such as improved
  32. type checking of variable-length parameter lists, etc.).  The idea is to add a
  33. new style of prototype:
  34.  
  35. int execl (const char *path, const char *arg...);
  36.  
  37. This implies a variable number of parameters, but (in this case) all of type
  38. "const char *."  In my experience this is, after printf-type functions, the most
  39. common situation in which variable numbers of parameters arise - all the
  40. optional parameters are of the same type.  Unfortunately, the syntax is rather
  41. subtle.
  42.  
  43. I have also imagined other enhancements to the prototype concept - fixed
  44. parameters of a limited range of types, a variable but limited number of
  45. parameters, variable number of parameters of a limited range of types, constant
  46. parameters (to supply the trailing NULL for execl, for example) etc. - but these
  47. have a limited cost/benefit ratio.  The existing one - unlimited variable
  48. parameters of unlimited types - and the one I suggest here - unlimited variable
  49. parameters of a single type - seem to me the most common and important cases.
  50.  
  51. --
  52. Peter Curran                               pcurran@inforamp.net
  53.  
  54.